//
//  DisclaimerViewController.m
//  安好
//
//  Created by 冯凯 on 14-11-28.
//  Copyright (c) 2014年 lianchuangbrother. All rights reserved.
//

#import "DisclaimerViewController.h"

@interface DisclaimerViewController ()

@end

@implementation DisclaimerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self makeNavBar];
    self.view.backgroundColor = [UIColor whiteColor];
    self.mbPro = [[MBProgressHUD alloc]initWithView:self.view];
    [self.mbPro setLabelText:@"加载中 请稍后.."];
    [self.navigationController.view.superview addSubview:self.mbPro];
    
    [self viewWithWeb];
}

- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    if (self.isFromResister) {
        self.navigationController.navigationBar.translucent = YES;
    }
}
#pragma mark - 配置导航条
-(void)makeNavBar
{
    if (self.isFromAboutMe) {
    self.navigationItem.title = @"关于我们";

    }else{
        self.navigationItem.title = @"免责声明";
        if (self.isFromResister) {
            self.navigationController.navigationBar.translucent = NO;
        }
    }
    // 返回按钮图片
    UIBarButtonItem *backBtnImg = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"公用_返回.png"] style:UIBarButtonItemStylePlain target:self action:@selector(backMoreVC)];
    backBtnImg.tintColor = [UIColor whiteColor];
    self.navigationItem.leftBarButtonItem = backBtnImg;
}
#pragma mark 返回
- (void)backMoreVC
{
    if (self.isFromResister) {
        [self.navigationController dismissViewControllerAnimated:YES completion:nil];
    }else{
        [self.navigationController popViewControllerAnimated:YES];
    }
}
#pragma mark 免责声明
- (void)viewWithWeb
{
    UIWebView * webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - 64)];
    webView.delegate = self;
    if (self.isFromAboutMe) {
    self.urlString = [NSString stringWithFormat:@"http://m.niruoanhao.com/system/aboutus/"];

    }else{
    self.urlString = [NSString stringWithFormat:@"%@h/systom/disclaimer/",kBaseURL];
    }
    NSURLRequest *request =[NSURLRequest requestWithURL:[NSURL URLWithString:self.urlString]];
    [self.view addSubview: webView];
    [webView loadRequest:request];
}
#pragma mark webViewDelegate
- (void) webViewDidStartLoad:(UIWebView *)webView
{
    self.mbPro.mode = MBProgressHUDModeIndeterminate;
    [self.mbPro show:YES];
}
- (void) webViewDidFinishLoad:(UIWebView *)webView
{
    self.mbPro.mode = MBProgressHUDModeIndeterminate;
    [self.mbPro hide:YES];
    
}
- (void) webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
    self.mbPro.mode = MBProgressHUDModeIndeterminate;
    [self.mbPro hide:YES];
    
}
 - (void)viewDidAppear:(BOOL)animated
{
    self.mbPro.mode = MBProgressHUDModeIndeterminate;
    [self.mbPro hide:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
